<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>抄表</title>
		<link rel="stylesheet" href="css/muse-ui.css">
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic">
		<link rel="stylesheet" href="https://cdn.bootcss.com/material-design-icons/3.0.1/iconfont/material-icons.css">
		<link rel="stylesheet" href="css/muse-ui-loading.css">
		<link rel="stylesheet" href="https://at.alicdn.com/t/font_951857_sr7zod4vu4.css">
		<script src="js/vue.min.js"></script>
		<script src="js/muse-ui.js"></script>
		<script src="js/muse-ui-loading.js"></script>
		<script src="js/muse-ui-toast.js"></script>
		<script src="js/axios.min.js"></script>
		<script src="js/mui.min.js"></script>
		<script src="js/utils.js"></script>
		<style>
			.container{
				height:calc(100vh);
				width: 100%;
				padding: 20px;
			}
			.container input {
				color: #ff4081;
			}
			.login-head{
				margin-top: 20%;
				width: 100%;
				text-align: center;
			}
			.icon-denglu{
				color: #fff;
				font-size: 70px;
			}
		</style>
	</head>
	<body>
		<div id="body">
			<mu-appbar style="width: 100%;position: fixed;top: 0;padding-top: 20px;height: auto;" color="secondary">
				<mu-button icon slot="left" @click="util.back()">
					<mu-icon value="arrow_back"></mu-icon>
				</mu-button>
				自助抄表
			</mu-appbar>
			<mu-container style="padding-top: 116px;">
				<mu-paper :z-depth="2" style="padding:10px;display: flex;justify-content: space-between;align-items: center;"
				 v-for="(item,index) in meterList" :key="index">
					<div style="display: flex;align-items: center;">
						<img src="img/meter.png" />
						<div>
							<div>
								<span style="font-weight: bold;">编号:</span>
								{{item.no}}
							</div>
							<div>
								<span style="font-weight: bold;">当前读数:</span>
								{{item.gasConsume}}
								<span style="color: red;">m³</span>
							</div>
						</div>
					</div>
					<div>
						<mu-button color="secondary" small @click="goRecordMeter(item.id)">抄表</mu-button>
						<div style="margin-top: 15px;">
							<mu-button small @click="goMeterRecord(item)">记录</mu-button>
						</div>
					</div>
				</mu-paper>
			</mu-container>
		</div>
	</body>
	<script type="text/javascript">
		var vm = new Vue({
			el: "#body",
			data() {
				return {
					meterList: [],
				}
			},
			methods: {
				goRecordMeter(meterId) {
					var params = {
						meterId: meterId
					}
					util.ajax("/meter/checkIsCanRecord", params, data => {
						if (data.code == 1) {
							util.setData("meterId", meterId);
							util.openWindow("recordMeter.html");
						} else {
							util.tip(data.msg, 5000);
						}
					})
				},
				getMeterListByUserId() {
					util.ajax("/api/method/getMeterListByUserId", null, data => {
						this.meterList = data.object;
					})
				},
				goMeterRecord(meter) {
					util.setData("meter", meter);
					util.openWindow("meterRecord.html")
				},
			}
		})
		document.addEventListener('plusready', function() {
			vm.getMeterListByUserId();
		});
	</script>
</html>
